{% load ordering %}
<div class="follow_item">
    <div class="follow_avatar">
        {% if user_follow.avatar %}
            <img src="{{ user_follow.avatar.url }}">
        {% else %}
            <img src="{{ STATIC_URL }}/images/default.jpg">
        {% endif %}
    </div>
    <div class="follow_info">
        <div>
            <a href="{% url my_items_root user_follow.username %}">
                {{ user_follow.get_username }}
            </a>
        </div>
        <div>
            {% with last_comment=user_follow.get_last_comment %}
                {% if last_comment %}
                    Last comment
                    <a href="{% url item_filter 'popular' last_comment.item.slug %}">
                        {{ last_comment.comment }}
                    </a>
                {% endif %}
            {% endwith %}
        </div>
    </div>
    <div class="form_follow">
        {% if user.is_authenticated %}
            {% if user != user_follow %}
                {%  with is_following=user|args:user_follow|call:"is_following"  %}
                    <form class="user_follow_form" id="user_follow_form{{ item.id }}" method="POST"
                          action="/user/profile/{% if is_following %}unfollow{% else %}follow{% endif %}/">
                        {% csrf_token %}
                        <input type="hidden" name="follow" value="{{ user_follow.id }}">
                        <input type="hidden" name="profile" value="{{ profile_user.id }}">
                        {% if is_following  %}
                            <input type="submit" class="unfollow_button submit_button" value="Following">
                        {% else %}
                            <input type="submit" class="submit_button" value="Follow">
                        {% endif %}
                    </form>
                {% endwith %}
            {% endif %}
        {% else %}
            <a class="submit_button auth_required gray" id="submit_button" href="#">Follow</a>
        {% endif %}
    </div>
</div>